//
//  DiscoverView.m
//  MyMicroBlog
//
//  Created by Apple on 16/9/22.
//  Copyright © 2016年 Apple. All rights reserved.
//

#import "DiscoverView.h"
#import "UIView+Extension.h"
@interface DiscoverView()
//搜索输入框
@property(weak,nonatomic)IBOutlet UITextField *discoverTextField;
//搜索按钮
@property(weak,nonatomic)IBOutlet UIButton *discoverBtn;
//搜索输入框右边约束
@property(weak,nonatomic)IBOutlet NSLayoutConstraint *discoverTextFieldRightConstraint;

@end

@implementation DiscoverView
+(instancetype)discoverV{
    return [[NSBundle mainBundle]loadNibNamed:@"DiscoverView" owner:self options:nil].lastObject;
}
//文本开始编辑改变右边约束
-(IBAction)editBegin:(id)sender{
    _discoverTextFieldRightConstraint.constant = _discoverBtn.width;
    [UIView animateWithDuration:0.3 animations:^{
        [self layoutIfNeeded];
    }];
}
//按钮点击事件
-(IBAction)discoverBtnClick:(id)sender{
    //文本框辞去第一响应者,修改约束
    [_discoverTextField resignFirstResponder];
    _discoverTextFieldRightConstraint.constant = 0;
    [UIView animateWithDuration:0.3 animations:^{
        [self layoutIfNeeded];
    }];
}

-(void)awakeFromNib{
    [super awakeFromNib];
    //设置文本输入框的属性
    _discoverTextField.layer.borderColor = [UIColor lightGrayColor].CGColor;
    _discoverTextField.layer.borderWidth = 5;
    _discoverTextField.layer.cornerRadius = 10;
    _discoverTextField.layer.masksToBounds = YES;
}

@end
